// 远期房态相关API接口

// 房型状态接口
export interface RoomStatus {
  available: number; // 可售
  occupied: number; // 在住
  booked: number; // 预订
  maintenance: number; // 维修
}

// 房型信息接口
export interface RoomType {
  id: string;
  roomType: string; // 房型名称
  totalRooms: number; // 总房间数
  status: Record<string, RoomStatus>; // 按日期索引的状态
}

// 日期信息接口
export interface DateInfo {
  date: string; // 日期 YYYY-MM-DD
  dayOfWeek: string; // 星期几
  display: string; // 显示格式
}

// 查询参数接口
export interface FutureRoomStatusQuery {
  startDate: string; // 开始日期
  endDate: string; // 结束日期
  sortType: 'room-type' | 'date' | 'room'; // 排序类型
  showRoomPrice: boolean; // 是否显示房价
}

// 统计信息接口
export interface RoomStatistics {
  soldRooms: number; // 已售房数
  availableRooms: number; // 可售房数
  soldRate: string; // 已售率
  availableRate: string; // 可售率
  averagePrice: string; // 平均房价
  estimatedRevenue: string; // 预计营收
}

// 远期房态响应接口
export interface FutureRoomStatusResponse {
  roomTypes: RoomType[];
  dateList: DateInfo[];
  statistics: RoomStatistics;
}

// 获取远期房态数据
export function getFutureRoomStatus(
  params: FutureRoomStatusQuery,
): Promise<FutureRoomStatusResponse> {
  return new Promise((resolve) => {
    setTimeout(() => {
      // 模拟数据
      const mockData: FutureRoomStatusResponse = {
        roomTypes: [
          {
            id: '1',
            roomType: '不标准双床房',
            totalRooms: 32,
            status: {
              '2025-08-17': {
                available: 30,
                occupied: 0,
                booked: 1,
                maintenance: 1,
              },
              '2025-08-18': {
                available: 31,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
              '2025-08-19': {
                available: 31,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
              '2025-08-20': {
                available: 31,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
              '2025-08-21': {
                available: 31,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
              '2025-08-22': {
                available: 31,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
            },
          },
          {
            id: '2',
            roomType: '总统房',
            totalRooms: 12,
            status: {
              '2025-08-17': {
                available: 10,
                occupied: 0,
                booked: 0,
                maintenance: 2,
              },
              '2025-08-18': {
                available: 10,
                occupied: 0,
                booked: 0,
                maintenance: 2,
              },
              '2025-08-19': {
                available: 10,
                occupied: 0,
                booked: 0,
                maintenance: 2,
              },
              '2025-08-20': {
                available: 10,
                occupied: 0,
                booked: 0,
                maintenance: 2,
              },
              '2025-08-21': {
                available: 10,
                occupied: 0,
                booked: 0,
                maintenance: 2,
              },
              '2025-08-22': {
                available: 10,
                occupied: 0,
                booked: 0,
                maintenance: 2,
              },
            },
          },
          {
            id: '3',
            roomType: '三人间',
            totalRooms: 0,
            status: {
              '2025-08-17': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-18': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-19': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-20': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-21': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-22': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
            },
          },
          {
            id: '4',
            roomType: '标间D',
            totalRooms: 0,
            status: {
              '2025-08-17': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-18': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-19': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-20': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-21': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-22': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
            },
          },
          {
            id: '5',
            roomType: '套间D',
            totalRooms: 0,
            status: {
              '2025-08-17': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-18': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-19': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-20': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-21': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-22': {
                available: 0,
                occupied: 0,
                booked: 0,
                maintenance: 0,
              },
            },
          },
          {
            id: '6',
            roomType: '舒适大床房',
            totalRooms: 17,
            status: {
              '2025-08-17': {
                available: 16,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
              '2025-08-18': {
                available: 16,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
              '2025-08-19': {
                available: 16,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
              '2025-08-20': {
                available: 16,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
              '2025-08-21': {
                available: 16,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
              '2025-08-22': {
                available: 16,
                occupied: 0,
                booked: 0,
                maintenance: 1,
              },
            },
          },
          {
            id: '7',
            roomType: '标准双床房',
            totalRooms: 147,
            status: {
              '2025-08-17': {
                available: 144,
                occupied: 3,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-18': {
                available: 145,
                occupied: 2,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-19': {
                available: 145,
                occupied: 2,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-20': {
                available: 145,
                occupied: 2,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-21': {
                available: 145,
                occupied: 2,
                booked: 0,
                maintenance: 0,
              },
              '2025-08-22': {
                available: 145,
                occupied: 2,
                booked: 0,
                maintenance: 0,
              },
            },
          },
        ],
        dateList: [
          {
            date: '2025-08-17',
            dayOfWeek: '星期天',
            display: '2025-08-17[星期天]',
          },
          {
            date: '2025-08-18',
            dayOfWeek: '星期一',
            display: '2025-08-18[星期一]',
          },
          {
            date: '2025-08-19',
            dayOfWeek: '星期二',
            display: '2025-08-19[星期二]',
          },
          {
            date: '2025-08-20',
            dayOfWeek: '星期三',
            display: '2025-08-20[星期三]',
          },
          {
            date: '2025-08-21',
            dayOfWeek: '星期四',
            display: '2025-08-21[星期四]',
          },
          {
            date: '2025-08-22',
            dayOfWeek: '星期五',
            display: '2025-08-22[星期五]',
          },
        ],
        statistics: {
          soldRooms: 4,
          availableRooms: 216,
          soldRate: '1.79',
          availableRate: '96.43',
          averagePrice: '68.01',
          estimatedRevenue: '340.03',
        },
      };

      resolve(mockData);
    }, 500);
  });
}

// 导出远期房态数据
export function exportFutureRoomStatus(
  params: FutureRoomStatusQuery,
): Promise<string> {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve('远期房态数据导出成功');
    }, 1000);
  });
}

// 刷新远期房态数据
export function refreshFutureRoomStatus(
  params: FutureRoomStatusQuery,
): Promise<FutureRoomStatusResponse> {
  return getFutureRoomStatus(params);
}
